local Tafang = fk.CreateSkill {
  name = "Tafang",
  anim_type = "defensive",
  tags = { Skill.Compulsory },
}


Fk:loadTranslationTable {
  ["Tafang"] = "塌房",
  [":Tafang"] = "锁定技，你使用黑色牌的伤害+1，并令目标随机弃置一种颜色的所有手牌；当你受到其他伤害时你对伤害来源造成2点火属性伤害。",
}

Tafang:addEffect(fk.CardUsing, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self.name) and target == player and data.card and data.card.color == Card.Black
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    data.additionalDamage = (data.additionalDamage or 0) + 1
    if #data.tos == 0 then return end
    for _, to in ipairs(data.tos) do
      if not to:isNude() then
        local to_discard = {}
        local handcards = to:getCardIds("h")
        for _, id in ipairs(handcards) do
          local c = Fk:getCardById(id)
          if math.random(1, 100) <= 50 then
            if c.color == Card.Black then
              table.insert(to_discard, id)
            end
          else
            if c.color == Card.Red then
              table.insert(to_discard, id)
            end
          end
          if #to_discard > 0 then
            room:moveCardTo(to_discard, Card.DiscardPile, nil, fk.ReasonDiscard, self.name, nil, true, player)
          end
        end
      end
    end
  end,
})

Tafang:addEffect(fk.DamageInflicted, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(Tafang.name) and target == player and data.from ~= player
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:damage({
      from = player,
      to = data.from,
      damage = 2,
      damageType = fk.FireDamage,
      skillName = Tafang.name
    })
  end,
})


return Tafang